//
//  AddNewDepositViewController.m
//  ShoppingExperience
//
//  Created by LiYinDi on 15/9/27.
//  Copyright (c) 2015年 RuiBen. All rights reserved.
//

#import "AddNewDepositViewController.h"
#import "SearchMemberTableViewCell.h"
#import "FPNumberPadView.h"
#import "GuideListTableViewCell.h"
//#import "ChengSeTableViewCell.h"
#import "CaptureViewController.h"
#import "PassImageDelegate.h"
#import "UpYun.h"
#import "CashierViewController.h"


@interface AddNewDepositViewController ()<FPNumberPadViewDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate,PassImageDelegate>
{
    CashierViewController *cashierVC;
    //NSString *memberCodeStr;
    NSInteger imageBtnTag;
    NSMutableArray *cashierGuideNameArray;
    NSMutableArray *cashierGuideCodeArray;
    NSMutableArray *upYunImageArray;
    BOOL isOpened;
    BOOL popIsOpen;
    NSInteger popTag;
    NSString *openIdStr;
    
    NSMutableArray *memberCodeArray;
    NSMutableArray *memberNameArray;
    NSMutableArray *memberPhoneArray;
    NSMutableArray *memberGradeArray;
    NSMutableArray *memberAddressArray;
    NSMutableArray *memberIntegralArray;
    NSMutableArray *memberIntegralAmountArray;
    NSMutableArray *memberSexArray;
}
@end

@implementation AddNewDepositViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    if (cashierVC.view!=nil) {
        
        [cashierVC removeFromParentViewController];
        [cashierVC.view removeFromSuperview];
        
    }

    // Do any additional setup after loading the view from its nib.
     [self initAddDeposit];
    
}
-(void)initAddDeposit
{
    _chengseListBtn.titleLabel.text=@"";
    _zhushiListBtn.titleLabel.text=@"";
    _shipinListBtn.titleLabel.text=@"";
    
    FPNumberPadView *numberPadView1 = [[FPNumberPadView alloc] initWithFrame:CGRectMake(0, 0, 948, 340)];
    // numberPadView.FPNumberPaddelegate=self;
    numberPadView1.textField = _depositAmountTextField;
    FPNumberPadView *numberPadView2 = [[FPNumberPadView alloc] initWithFrame:CGRectMake(0, 0, 948, 340)];
    // numberPadView.FPNumberPaddelegate=self;
    numberPadView2.textField = _minAmountTextField;
    FPNumberPadView *numberPadView3 = [[FPNumberPadView alloc] initWithFrame:CGRectMake(0, 0, 948, 340)];
    // numberPadView.FPNumberPaddelegate=self;
    numberPadView3.textField = _maxAmountTextField;
  //  memberCodeStr=@"";
    imageBtnTag=10000;
    cashierGuideNameArray=[NSMutableArray array];
    cashierGuideCodeArray=[NSMutableArray array];
    upYunImageArray=[NSMutableArray array];
    
    _memberAndPhoneLabel.text=_memberAndPhoneStr;
    _memberGradeLabel.text=_gradeStr;
    _memberIntegralLabel.text=_integralStr;
    
  
    [Global resizeForLable:_memberAndPhoneLabel WithText:_memberAndPhoneLabel.text parentView:self.view];
    [Global resizeForLable:_memberGradeLabel WithText:_memberGradeLabel.text parentView:self.view];
        //_memberGradeLabel.text=[severDataDict.dataDict objectForKey:@"Grade"];
   
    CGRect frame1=_memberGradeTagLabel.frame;
    frame1.origin.x=_memberAndPhoneLabel.frame.origin.x+_memberAndPhoneLabel.frame.size.width+12;
    _memberGradeTagLabel.frame=frame1;
    
    CGRect frame2=_memberGradeLabel.frame;
    frame2.origin.x=_memberGradeTagLabel.frame.origin.x+_memberGradeTagLabel.frame.size.width+2;
    _memberGradeLabel.frame=frame2;
    
    CGRect frame3=_memberIntegralTagLabel.frame;
    frame3.origin.x=_memberGradeLabel.frame.origin.x+_memberGradeLabel.frame.size.width+12;
    _memberIntegralTagLabel.frame=frame3;
    
    CGRect frame4=_memberIntegralLabel.frame;
    frame4.origin.x=_memberIntegralTagLabel.frame.origin.x+_memberIntegralTagLabel.frame.size.width+2;
    _memberIntegralLabel.frame=frame4;

   
    popTag=0;
    isOpened=NO;
    popIsOpen=NO;
    CGRect frameP=_popScrollView.frame;
    frameP.size.height=1;
    [_popScrollView setFrame:frameP];
    
    _popScrollView.hidden=YES;
    
    
    CGRect viewFrame4=_photoPickerViewContainer.frame;
    viewFrame4.origin.y=768;
    _photoPickerViewContainer.frame=viewFrame4;
    
    CGRect frame0=_addPictureButton.frame;
    frame0.origin.x=16;
    frame0.origin.y=10;
    _addPictureButton.frame=frame0;
    for (UIView *v in _pictureView.subviews) {
        if (v.tag!=90) {
            
            [v removeFromSuperview];
        }
        
    }
    CGRect viewFrame0=_pictureViewLineLabel.frame;
    viewFrame0.origin.y= _pictureView.frame.size.height-1;
    _pictureViewLineLabel.frame=viewFrame0;

    CGRect viewFrame1=_remarkViewContainer.frame;
    viewFrame1.origin.y=_pictureView.frame.origin.y+_pictureView.frame.size.height+15;
    _remarkViewContainer.frame=viewFrame1;
    [_addDepositScrollView setContentSize:CGSizeMake(0, _remarkViewContainer.frame.origin.y+_remarkViewContainer.frame.size.height)];
    [_addDepositScrollView setShowsVerticalScrollIndicator:NO];
    [_addDepositScrollView setScrollEnabled:YES];
    
    _addDepositRemarkView.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
    _addDepositRemarkView.layer.borderWidth= 1.0f;
    _addDepositRemarkView.layer.cornerRadius=3;
    
    
    [_addDepositAlphaView setBackgroundColor:[Global parseColor:WESTORE_TRANSCLUCENT]];
    [_addDepositAlphaView addTarget:self action:@selector(addDepositAlphaViewClick) forControlEvents:UIControlEventTouchUpInside];
    
    [_chengseListBtn addTarget:self action:@selector(chengSeListBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [_zhushiListBtn addTarget:self action:@selector(chengSeListBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [_shipinListBtn addTarget:self action:@selector(chengSeListBtnClick:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)chengSeListBtnClick:(UIButton *)sender
{
    [_minAmountTextField resignFirstResponder];
    [_maxAmountTextField resignFirstResponder];
    [_depositAmountTextField resignFirstResponder];
    [_addDepositScrollView bringSubviewToFront:_popScrollView];
    
    if (popIsOpen) {
        _popScrollView.hidden=YES;
        [UIView animateWithDuration:0.5 animations:^{
            
            CGRect frame=_popScrollView.frame;
            
            frame.size.height=1;
            [_popScrollView setFrame:frame];
            
        } completion:^(BOOL finished){
            popIsOpen=NO;
        }];
        
    }
    else
    {
        
        for (UIView *v in _popScrollView.subviews) {
            
            [v removeFromSuperview];
        }
        
        _popScrollView.hidden=NO;
        [UIView animateWithDuration:0.5 animations:^{
            
            CGRect frame=_popScrollView.frame;
            if (sender.tag==1000) {
                [self requestChengSe];
                frame.origin.y=357;
                frame.size.height=366;
            }
            else if(sender.tag==1001)
            {
                [self requestZhuShi];
                frame.origin.y=418;
                frame.size.height=310;
            }
            else if(sender.tag==1002)
            {
                [self requestShiPin];
                frame.origin.y=467;
                frame.size.height=276;
            }
            
            
            [_popScrollView setFrame:frame];
            
        } completion:^(BOOL finished){
            popIsOpen=YES;
        }];
        
    }
    
}
-(void)requestChengSe
{
    
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        
        [HttpRequest requestData:@"Guide/FinenessList" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            
            // [_cashierSearchMemberTextField resignFirstResponder];
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    
                    if ([severDataDict.dataDict objectForKey:@"ResultString"]!= [NSNull null] )
                    {
//                        NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
//                        //  [Global showTextHud:requestResultStr view:self.view];
//                        [Global showTextHudSub:requestResultStr view:self.view];
                        
                        NSMutableArray *dataLineArray=[NSMutableArray arrayWithArray:[severDataDict.dataDict objectForKey:@"DataLine"]];
                        NSMutableArray *nameArray=[NSMutableArray array];
                        NSMutableArray *codeArray=[NSMutableArray array];
                        for (int i=0; i<dataLineArray.count; i++) {
                            [codeArray addObject:[[dataLineArray objectAtIndex:i] objectForKey:@"FinenessCode"]];
                            [nameArray addObject:[[dataLineArray objectAtIndex:i] objectForKey:@"FinenessName"]];
                        }
                        for (UIView *v in _popScrollView.subviews) {
                            
                            [v removeFromSuperview];
                        }
                        _popScrollView.hidden=NO;
                        popIsOpen=YES;
                        
                        for (int i=0; i<nameArray.count; i++) {
                            
                            UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
                            CGRect rect=button.frame;
                            rect.size.height=50;
                            rect.size.width=545;
                            rect.origin.x=10;
                            rect.origin.y=50*i;
                            button.frame=rect;
                            button.tag=100+i;
                            [button setBackgroundColor:[UIColor clearColor]];
                            [button setTitle:[nameArray objectAtIndex:i] forState:UIControlStateNormal];
                            
                            [button setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
                            [button addTarget:self action:@selector(selectNameBtn:) forControlEvents:UIControlEventTouchUpInside];
                            
                            
                            UILabel *textLabel=[[UILabel alloc] initWithFrame:CGRectMake(25, 20,400, 20)];
                            [textLabel setText:[nameArray objectAtIndex:i]];
                            [textLabel setFont:[UIFont fontWithName:@"Helvetica" size:16]];
                            [textLabel setBackgroundColor:[UIColor clearColor]];
                            [button addSubview:textLabel];
                            
                            UILabel *codeLabel=[[UILabel alloc] initWithFrame:CGRectMake(0,0,1,1)];
                            codeLabel.text=[codeArray objectAtIndex:i];
                            codeLabel.tag=5000;
                            codeLabel.hidden=YES;
                            [button addSubview:codeLabel];
                            
                            UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(5,49, 590, 1)];
                            // NSLog(@"lineLabel.origin.y ==%f",lineLabel.frame.origin.y);
                            [lineLabel setBackgroundColor:[UIColor clearColor]];
                            [lineLabel setText:@"－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－"];
                            [lineLabel setTextColor:[UIColor colorWithRed:241.0f/255.0f green:241.0f/255.0f blue:241.0f/255.0f alpha:1.0f]];
                            
                            [button addSubview:lineLabel];
                            [_popScrollView addSubview:button];
                            
                            NSInteger index= [nameArray indexOfObject:_chengseTextField.text];
                            if (index!=NSNotFound) {
                                popTag=index;
                                
                                
                                if (i==popTag) {
                                    
                                    UIImageView *selectImageview=[[UIImageView alloc] initWithFrame:CGRectMake(540, 11, 30, 30)];
                                    [selectImageview setImage:[UIImage imageNamed:@"xuanzhong_.png"]];
                                    [button addSubview:selectImageview];
                                }
                            }
                            
                            
                        }
                        
                        
                        [_popScrollView setContentSize:CGSizeMake(0, 50*nameArray.count)];
                        [_popScrollView setShowsVerticalScrollIndicator:NO];
                        [_popScrollView setScrollEnabled:YES];
                    }
                    
                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                        
//                        if (_timer!=nil) {
//                            [_timer invalidate];
//                            _timer=nil;
//                        }
                        [Global loginViewController:self noteStr:requestResultStr];
                        //    [Global loginViewController:self];
                    }
                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
    }
}

-(void)requestShiPin
{
    
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        
        [HttpRequest requestData:@"Guide/GetMIThrtypeList" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            
            // [_cashierSearchMemberTextField resignFirstResponder];
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    
                    if ([severDataDict.dataDict objectForKey:@"ResultString"]!= [NSNull null] )
                    {
//                        NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
//                        //  [Global showTextHud:requestResultStr view:self.view];
//                        [Global showTextHudSub:requestResultStr view:self.view];
                        
                        NSMutableArray *dataLineArray=[NSMutableArray arrayWithArray:[severDataDict.dataDict objectForKey:@"DataLine"]];
                        NSMutableArray *nameArray=[NSMutableArray array];
                        NSMutableArray *codeArray=[NSMutableArray array];
                        for (int i=0; i<dataLineArray.count; i++) {
                            [codeArray addObject:[[dataLineArray objectAtIndex:i] objectForKey:@"IThrtypeCode"]];
                            [nameArray addObject:[[dataLineArray objectAtIndex:i] objectForKey:@"IThrtypeName"]];
                        }
                        for (UIView *v in _popScrollView.subviews) {
                            
                            [v removeFromSuperview];
                        }
                        _popScrollView.hidden=NO;
                        popIsOpen=YES;
                        
                        for (int i=0; i<nameArray.count; i++) {
                            
                            UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
                            CGRect rect=button.frame;
                            rect.size.height=50;
                            rect.size.width=545;
                            rect.origin.x=20;
                            rect.origin.y=50*i;
                            button.frame=rect;
                            button.tag=400+i;
                            [button setBackgroundColor:[UIColor clearColor]];
                            [button setTitle:[nameArray objectAtIndex:i] forState:UIControlStateNormal];
                            
                            [button setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
                            [button addTarget:self action:@selector(selectNameBtn:) forControlEvents:UIControlEventTouchUpInside];
                            
                            
                            UILabel *textLabel=[[UILabel alloc] initWithFrame:CGRectMake(25, 20,400, 20)];
                            [textLabel setText:[nameArray objectAtIndex:i]];
                            [textLabel setFont:[UIFont fontWithName:@"Helvetica" size:16]];
                            [textLabel setBackgroundColor:[UIColor clearColor]];
                            [button addSubview:textLabel];
                            
                            UILabel *codeLabel=[[UILabel alloc] initWithFrame:CGRectMake(0,0,1,1)];
                            codeLabel.text=[codeArray objectAtIndex:i];
                            codeLabel.tag=5000;
                            codeLabel.hidden=YES;
                            [button addSubview:codeLabel];
                            
                            UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0,49, 590, 1)];
                            // NSLog(@"lineLabel.origin.y ==%f",lineLabel.frame.origin.y);
                            [lineLabel setBackgroundColor:[UIColor clearColor]];
                            [lineLabel setText:@"－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－"];
                            [lineLabel setTextColor:[UIColor colorWithRed:241.0f/255.0f green:241.0f/255.0f blue:241.0f/255.0f alpha:1.0f]];
                            
                            [button addSubview:lineLabel];
                            [_popScrollView addSubview:button];
                            
                            NSInteger index= [nameArray indexOfObject:_shiPinTextField.text];
                            if (index!=NSNotFound) {
                                popTag=index;
                                
                                
                                if (i==popTag) {
                                    
                                    UIImageView *selectImageview=[[UIImageView alloc] initWithFrame:CGRectMake(530, 11, 30, 30)];
                                    [selectImageview setImage:[UIImage imageNamed:@"xuanzhong_.png"]];
                                    [button addSubview:selectImageview];
                                }
                            }
                            
                            
                        }
                        
                        
                        [_popScrollView setContentSize:CGSizeMake(0, 50*nameArray.count)];
                        [_popScrollView setShowsVerticalScrollIndicator:NO];
                        [_popScrollView setScrollEnabled:YES];
                    }
                    
                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
//                        
//                        if (_timer!=nil) {
//                            [_timer invalidate];
//                            _timer=nil;
//                        }
                        [Global loginViewController:self noteStr:requestResultStr];
                        //    [Global loginViewController:self];
                    }
                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
    }
}
-(void)requestZhuShi
{
    
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        [params setObject:@"ProductName2" forKey:@"KeyWord"];
        
        [HttpRequest requestData:@"Common/GetDictList" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            
            // [_cashierSearchMemberTextField resignFirstResponder];
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    
                    if ([severDataDict.dataDict objectForKey:@"ResultString"]!= [NSNull null] )
                    {
//                        NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
//                        //  [Global showTextHud:requestResultStr view:self.view];
//                        
//                        [Global showTextHudSub:requestResultStr view:self.view];
                        
                        NSMutableArray *dataLineArray=[NSMutableArray arrayWithArray:[severDataDict.dataDict objectForKey:@"DataLine"]];
                        NSMutableArray *nameArray=[NSMutableArray array];
                        NSMutableArray *codeArray=[NSMutableArray array];
                        for (int i=0; i<dataLineArray.count; i++) {
                            [codeArray addObject:[[dataLineArray objectAtIndex:i] objectForKey:@"Code"]];
                            [nameArray addObject:[[dataLineArray objectAtIndex:i] objectForKey:@"Name"]];
                        }
                        for (UIView *v in _popScrollView.subviews) {
                            
                            [v removeFromSuperview];
                        }
                        _popScrollView.hidden=NO;
                        popIsOpen=YES;
                        
                        for (int i=0; i<nameArray.count; i++) {
                            
                            UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
                            CGRect rect=button.frame;
                            rect.size.height=50;
                            rect.size.width=545;
                            rect.origin.x=20;
                            rect.origin.y=50*i;
                            button.frame=rect;
                            button.tag=800+i;
                            [button setBackgroundColor:[UIColor clearColor]];
                            [button setTitle:[nameArray objectAtIndex:i] forState:UIControlStateNormal];
                            
                            [button setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
                            [button addTarget:self action:@selector(selectNameBtn:) forControlEvents:UIControlEventTouchUpInside];
                            
                            UILabel *codeLabel=[[UILabel alloc] initWithFrame:CGRectMake(0,0,1,1)];
                            codeLabel.text=[codeArray objectAtIndex:i];
                            codeLabel.tag=5000;
                            codeLabel.hidden=YES;
                            [button addSubview:codeLabel];
                            
                            UILabel *textLabel=[[UILabel alloc] initWithFrame:CGRectMake(25, 20,400, 20)];
                            [textLabel setText:[nameArray objectAtIndex:i]];
                            [textLabel setFont:[UIFont fontWithName:@"Helvetica" size:16]];
                            [textLabel setBackgroundColor:[UIColor clearColor]];
                            [button addSubview:textLabel];
                            
                            
                            
                            UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0,49, 590, 1)];
                            // NSLog(@"lineLabel.origin.y ==%f",lineLabel.frame.origin.y);
                            [lineLabel setBackgroundColor:[UIColor clearColor]];
                            [lineLabel setText:@"－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－"];
                            [lineLabel setTextColor:[UIColor colorWithRed:241.0f/255.0f green:241.0f/255.0f blue:241.0f/255.0f alpha:1.0f]];
                            
                            [button addSubview:lineLabel];
                            [_popScrollView addSubview:button];
                            
                            NSInteger index= [nameArray indexOfObject:_zhuShiTextField.text];
                            if (index!=NSNotFound) {
                                popTag=index;
                                
                                
                                if (i==popTag) {
                                    
                                    UIImageView *selectImageview=[[UIImageView alloc] initWithFrame:CGRectMake(530, 11, 30, 30)];
                                    [selectImageview setImage:[UIImage imageNamed:@"xuanzhong_.png"]];
                                    [button addSubview:selectImageview];
                                }
                            }
                            
                            
                        }
                        
                        
                        [_popScrollView setContentSize:CGSizeMake(0, 50*nameArray.count)];
                        [_popScrollView setShowsVerticalScrollIndicator:NO];
                        [_popScrollView setScrollEnabled:YES];
                    }
                    
                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                        
//                        if (_timer!=nil) {
//                            [_timer invalidate];
//                            _timer=nil;
//                        }
                        [Global loginViewController:self noteStr:requestResultStr];
                        //    [Global loginViewController:self];
                    }
                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
    }
}


-(void)selectNameBtn:(UIButton *)sender
{
    if (sender.tag<399) {
        UIImageView *selectImageview=[[UIImageView alloc] initWithFrame:CGRectMake(540, 11, 30, 30)];
        [selectImageview setImage:[UIImage imageNamed:@"xuanzhong_.png"]];
        [sender addSubview:selectImageview];
        popTag=sender.tag-100;
        _chengseTextField.text=sender.titleLabel.text;
        UILabel *codeLabel=(UILabel *)[sender  viewWithTag:5000] ;
        
        [_chengseListBtn setTitle:codeLabel.text forState:UIControlStateNormal];
        [_chengseListBtn setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
        
    }
    else if (sender.tag<799&&sender.tag>399)
    {
        UIImageView *selectImageview=[[UIImageView alloc] initWithFrame:CGRectMake(530, 11, 30, 30)];
        [selectImageview setImage:[UIImage imageNamed:@"xuanzhong_.png"]];
        [sender addSubview:selectImageview];
        popTag=sender.tag-400;
        _shiPinTextField.text=sender.titleLabel.text;
        UILabel *codeLabel=(UILabel *)[sender  viewWithTag:5000] ;
        
        [_shipinListBtn setTitle:codeLabel.text forState:UIControlStateNormal];
        [_shipinListBtn setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
        
    }
    else if (sender.tag>799)
    {
        UIImageView *selectImageview=[[UIImageView alloc] initWithFrame:CGRectMake(530, 11, 30, 30)];
        [selectImageview setImage:[UIImage imageNamed:@"xuanzhong_.png"]];
        [sender addSubview:selectImageview];
        
        popTag=sender.tag-800;
        _zhuShiTextField.text=sender.titleLabel.text;
        UILabel *codeLabel=(UILabel *)[sender  viewWithTag:5000] ;
        
        [_zhushiListBtn setTitle:codeLabel.text forState:UIControlStateNormal];
        [_zhushiListBtn setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
    }
    
    [UIView animateWithDuration:0.1f animations:^
     {
         CGRect frame1=_popScrollView.frame;
         frame1.size.height=1;
         [_popScrollView setFrame:frame1];
     }completion:^(BOOL finished) {
         _popScrollView.hidden=YES;
         popIsOpen=NO;
         
     }];
}

-(IBAction)addPictureBtnClick:(id)sender
{
    [UIView animateWithDuration:0.5f animations:^
     {
         CGRect viewFrame=_photoPickerViewContainer.frame;
         viewFrame.origin.y=0;
         _photoPickerViewContainer.frame=viewFrame;
     }completion:^(BOOL finished) {
         
         
     }];
    
}


-(IBAction)saveDepositBtnClick:(id)sender
{
   // isLoad=NO;
    [upYunImageArray removeAllObjects];
    if (_pictureView.subviews.count>2) {
        if ([Global getLoginToken].length>0) {
            [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
            NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
            [params setObject:[Global getLoginToken] forKey:@"Token"];
            [params setObject:@"DDemand" forKey:@"uploadType"];
            //   NSLog(@"params====%@",params);
            [HttpRequest requestLoginData:@"System/GetFormParams" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
                //  NSLog(@"serrr111==%@",severDataDict.dataDict);
                // [_cashierSearchMemberTextField resignFirstResponder];
                if (isSuccess) {
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                        [Global hideProgressHUDInternal:self.view];
                        [Global setUpYunUrl:[severDataDict.dataDict objectForKey:@"action"]];
                        // signatureStr=[severDataDict.dataDict objectForKey:@"signature"];
                        // policyStr=[severDataDict.dataDict objectForKey:@"policy"];
                        
                        [Global setSignatureStr:[severDataDict.dataDict objectForKey:@"signature"]];
                        [Global setPolicyStr:[severDataDict.dataDict objectForKey:@"policy"]];
                        
                        [self upToUpYun];
                    }
                    else
                    {
                        [Global hideProgressHUDInternal:self.view];
                        NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                        //  [Global showTextHud:requestResultStr view:self.view];
                        [Global showTextHudSub:requestResultStr view:self.view];
                        
                        if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                            [Global loginViewController:self noteStr:requestResultStr];
                            //   [Global loginViewController:self];
                        }
                        
                    }
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    [Global showTextHudSub:@"连接失败" view:self.view];
                }
            }];
        }
        
        
        //    [self upToUpYun];
    }
    else
    {
        // NSLog(@"14444477777");
        [self saveDepositToServer];
    }
}
-(void)upToUpYun
{
    __block NSInteger count=0;
    UpYun *uy = [[UpYun alloc] init];
    uy.successBlocker = ^(id data)
    {
        count++;
        // NSLog(@"count======%d",count );
        // NSLog(@"_pictureView.subviews.count======%d",_pictureView.subviews.count );
        
        NSString *imageURL;
        NSString *imageWIDTH;
        NSString *imageHEIGHT;
        imageURL=[data objectForKey:@"url"];
        imageWIDTH=[data objectForKey:@"image-width"];
        imageHEIGHT=[data objectForKey:@"image-height"];
        NSMutableDictionary *upYunImageDict=[NSMutableDictionary dictionary];
        [upYunImageDict setObject:imageURL forKey:@"ImageUrl"];
        [upYunImageDict setObject:imageWIDTH forKey:@"ImageWidth"];
        [upYunImageDict setObject:imageHEIGHT forKey:@"ImageHeigh"];
        [upYunImageArray addObject:upYunImageDict];
        if (count==_pictureView.subviews.count-2-(_pictureView.subviews.count-2)/2) {
            
            [Global hideProgressHUDInternal:self.view];
            [self saveDepositToServer];
        }
        
        
    };
    uy.failBlocker = ^(NSError * error)
    {
        [Global hideProgressHUDInternal:self.view];
         [Global showTextHudSub:@"上传失败" view:self.view];
//        NSString *message = [error.userInfo objectForKey:@"message"];
//        UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"error" message:message delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
//        [alert show];
        //  NSLog(@"%@",error);
    };
    uy.progressBlocker = ^(CGFloat percent, long long requestDidSendBytes)
    {
        // [_pv setProgress:0.3333333333+percent/3];
    };
    
    if (_memberAndPhoneLabel.text.length>0&&[_depositAmountTextField.text floatValue]>0) {
        
        [Global showIndeterminateHudSub:@"正上传UPYUN，请稍后。。。" delay:120 view:self.view];
        if (upYunImageArray.count==0) {
            
            for (UIView *v in _pictureView.subviews) {
                if (v.tag!=90&&v.tag>50) {
                    UIImageView *imageview=(UIImageView *)v;
                    UIImage *sampleImg=[self imageCompress:imageview.image];
                    
                    //            NSData *imageData = UIImageJPEGRepresentation(imageview.image,0.01);
                    //            //NSLog(@"imageData===%@",imageData);
                    //            UIImage *newImage = [UIImage imageWithData:imageData];
                    
                    uy.bucket=@"";
                    [uy uploadFile:sampleImg saveKey:[self getSaveKey]];
                }
                
            }
        }
        
        
    }
    else
    {
        if (_memberAndPhoneLabel.text.length==0)
        {
            UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"请选择会员" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
            [alert show];
            
        }
        
        
        else if ([_depositAmountTextField.text floatValue]==0)
        {
            UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"请输入定金金额" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
            [alert show];
            
        }
        
    }
    
}
-(void)saveDepositToServer
{
   // isLoad=NO;
    if (_memberAndPhoneLabel.text.length>0&&[_depositAmountTextField.text floatValue]>0) {
        
        if ([Global getLoginToken].length>0) {
            [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
            NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
            [params setObject:[Global getLoginToken] forKey:@"Token"];
            
            [params setObject:upYunImageArray forKey:@"DataLine"];
            [params setObject:_addDepositRemarkView.text forKey:@"Remark"];
            [params setObject:[Global getGuideCodeStr] forKey:@"GuideCode"];
            [params setObject:_minAmountTextField.text forKey:@"MinAmount"];
            [params setObject:_maxAmountTextField.text forKey:@"MaxAmount"];
            [params setObject:_memberCodeStr forKey:@"MemberCode"];
            [params setObject:_depositAmountTextField.text forKey:@"Subscription"];
            [params setObject:_chengseListBtn.titleLabel.text forKey:@"ProductName1"];
            [params setObject:_zhushiListBtn.titleLabel.text forKey:@"ProductName2"];
            [params setObject:_shipinListBtn.titleLabel.text forKey:@"ThrtypeCode"];
            
            //  NSLog(@"addddPARAM1111===%@",params);
            [HttpRequest requestData:@"Guide/EditDeposit" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
                if (isSuccess) {
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                        [Global hideProgressHUDInternal:self.view];
                        NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                        [Global showTextHudSub:requestResultStr view:self.view];
               
                        _minAmountTextField.text=@"";
                        _maxAmountTextField.text=@"";
                       // _guideNameLabel.text=@"";
                        _depositAmountTextField.text=@"";
                        //guideCodeStr=@"";
                        [_addDepositScrollView setContentOffset:CGPointMake(0, 0)];
                        CGRect viewFrame=_pictureView.frame;
                        viewFrame.size.height=118;
                        _pictureView.frame=viewFrame;
                        
                        CGRect viewFrame0=_pictureViewLineLabel.frame;
                        viewFrame0.origin.y= _pictureView.frame.size.height-1;
                        _pictureViewLineLabel.frame=viewFrame0;
                        

                        
                        CGRect viewFrame1=_remarkViewContainer.frame;
                        viewFrame1.origin.y=_pictureView.frame.origin.y+_pictureView.frame.size.height+15;
                        _remarkViewContainer.frame=viewFrame1;
                        
                        [_addDepositScrollView setContentSize:CGSizeMake(0, _remarkViewContainer.frame.origin.y+_remarkViewContainer.frame.size.height)];
                        
                        
                        _addDepositRemarkViewImage.hidden=NO;
                        _addDepositRemarkViewLabel.hidden=NO;
                        _addDepositRemarkView.text=@"";
                        for (UIView *v in _pictureView.subviews) {
                            if (v.tag!=90) {
                                
                                [v removeFromSuperview];
                            }
                            
                        }
                        
                        
                        CGRect viewFrame11=_addPictureButton.frame;
                        viewFrame11.origin.y=10;
                        viewFrame11.origin.x=16;
                        _addPictureButton.frame=viewFrame11;
                        NSString *numStr=[severDataDict.dataDict objectForKey:@"DocNum"];
                        
                        if ([self.delegate respondsToSelector:@selector(ConfirmAddDepositClick:)]) {
                            [self.delegate ConfirmAddDepositClick:numStr];
                        }

                        
                        
                    }
                    else
                    {
                        [Global hideProgressHUDInternal:self.view];
                        NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                        //  [Global showTextHud:requestResultStr view:self.view];
                        [Global showTextHudSub:requestResultStr view:self.view];
                        
                        if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                            [Global loginViewController:self noteStr:requestResultStr];
                            //    [Global loginViewController:self];
                        }
                        
                    }
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    [Global showTextHudSub:@"连接失败" view:self.view];
                }
            }];
            
        }
    }
    else
    {
        // NSLog(<#NSString *format, ...#>)
        if (_memberAndPhoneLabel.text.length==0)
        {
            UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"请选择会员" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
            [alert show];
            
        }
        
        
        else if ([_depositAmountTextField.text floatValue]==0)
        {
            UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"请输入定金金额" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
            [alert show];
            
        }
        
    }
    
}

-(void)imgBtnCLick:(UIButton *)sender
{
    imageBtnTag=sender.tag;
    [UIView animateWithDuration:0.5f animations:^
     {
         CGRect viewFrame=_photoPickerViewContainer.frame;
         viewFrame.origin.y=0;
         _photoPickerViewContainer.frame=viewFrame;
     }completion:^(BOOL finished) {
         
         
     }];
    
}

#pragma 拍照选择照片协议方法
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    //isLoad=YES;
    [UIApplication sharedApplication].statusBarHidden = NO;
    
    NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
    
    // NSData *data;
    
    if ([mediaType isEqualToString:@"public.image"]){
        
        //切忌不可直接使用originImage，因为这是没有经过格式化的图片数据，可能会导致选择的图片颠倒或是失真等现象的发生，从UIImagePickerControllerOriginalImage中的Origin可以看出，很原始，哈哈
        UIImage *originImage = [info objectForKey:UIImagePickerControllerOriginalImage];
        // NSLog(@"originImage.",originImage.size);
        //图片压缩，因为原图都是很大的，不必要传原图
        // UIImage *scaleImage = [self scaleImage:originImage toScale:1.0];
        //  UIImage *sampleImg=[self imageCompress:originImage];
        
        //以下这两步都是比较耗时的操作，最好开一个HUD提示用户，这样体验会好些，不至于阻塞界面
        //       if (UIImagePNGRepresentation(scaleImage) == nil) {
        //将图片转换为JPG格式的二进制数据
        //   data = UIImageJPEGRepresentation(scaleImage, 1.0);
        //        }
        //        else {
        ////          //  将图片转换为PNG格式的二进制数据
        //           data = UIImagePNGRepresentation(scaleImage);
        //       }
        
        
        
        //将二进制数据生成UIImage
        // UIImage *image = [UIImage imageWithData:data];
        
        // NSData *imageData = UIImageJPEGRepresentation(image,0.01);
        //NSLog(@"imageData===%@",imageData);
        // UIImage *newImage = [UIImage imageWithData:imageData];
        
        //将图片传递给截取界面进行截取并设置回调方法（协议）
        CaptureViewController *captureView = [[CaptureViewController alloc] init];
        captureView.delegate = self;
        captureView.image = originImage;
        //隐藏UIImagePickerController本身的导航栏
        picker.navigationBar.hidden = NO;
        [picker pushViewController:captureView animated:YES];
        
    }
}

#pragma mark - 图片回传协议方法
-(void)passImage:(UIImage *)image
{
    
    UIImage *sampleImg=image;
    //NSLog(@"sampleImg===%f,%f",sampleImg.size.width,sampleImg.size.height);
    // isLoad=NO;
    
    CGRect frame=_addPictureButton.frame;
    
    UIImageView *getImageView=(UIImageView *)[_pictureView viewWithTag:imageBtnTag+100];
    if (getImageView==nil) {
        
        UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame=frame;
        btn.tag=5*btn.frame.origin.y/100+btn.frame.origin.x/117;
        [btn addTarget:self action:@selector(imgBtnCLick:) forControlEvents:UIControlEventTouchUpInside];
        
        UIImageView *sampleImageView=[[UIImageView alloc] initWithFrame:frame];
        sampleImageView.tag=5*sampleImageView.frame.origin.y/100+sampleImageView.frame.origin.x/117+100;
        //  sampleImageView.tag=9;
        [sampleImageView setImage:sampleImg];
        [_pictureView addSubview:sampleImageView];
        [_pictureView addSubview:btn];
        // [selectePictureArray addObject:sampleImageView];
        // NSLog(@"btn.tag===%d",btn.tag);
        //NSLog(@"sampleImageView.tag===%d",sampleImageView.tag);
        
        CGRect frame1=_addPictureButton.frame;
        frame1.origin.x=_addPictureButton.frame.origin.x+_addPictureButton.frame.size.width+27;
        _addPictureButton.frame=frame1;
        if (frame1.origin.x>484) {
            frame1.origin.x=16;
            frame1.origin.y=115;
            _addPictureButton.frame=frame1;
            
            CGRect viewFrame=_pictureView.frame;
            viewFrame.size.height=223;
            _pictureView.frame=viewFrame;
            
        }
        if (frame1.origin.x>484&&frame1.origin.y==115) {
            _addPictureButton.hidden=YES;
        }
        CGRect viewFrame0=_pictureViewLineLabel.frame;
        viewFrame0.origin.y= _pictureView.frame.size.height-1;
        _pictureViewLineLabel.frame=viewFrame0;
        CGRect viewFrame1=_remarkViewContainer.frame;
        viewFrame1.origin.y=_pictureView.frame.origin.y+_pictureView.frame.size.height+15;
        _remarkViewContainer.frame=viewFrame1;
        
        //        CGRect viewFrame2=_saveBtn.frame;
        //        viewFrame2.origin.y=_remarkViewContainer.frame.origin.y+_remarkViewContainer.frame.size.height+20;
        //        _saveBtn.frame=viewFrame2;
        
        [_addDepositScrollView setContentSize:CGSizeMake(0, _remarkViewContainer.frame.origin.y+ _remarkViewContainer.frame.size.height+10)];
        [_addDepositScrollView setScrollEnabled:YES];
    }
    else
    {
        getImageView.image=sampleImg;
    }
    imageBtnTag=10000;
    
}

#pragma mark- 缩放图片
-(UIImage *)scaleImage:(UIImage *)image toScale:(float)scaleSize
{
    UIGraphicsBeginImageContext(CGSizeMake(image.size.width*scaleSize,image.size.height*scaleSize));
    [image drawInRect:CGRectMake(0, 0, image.size.width * scaleSize, image.size.height *scaleSize)];
    UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return scaledImage;
}

-(IBAction)albumOrCameraBtnClick:(UIButton *)sender
{
    CGRect viewFrame=_photoPickerViewContainer.frame;
    viewFrame.origin.y=768;
    _photoPickerViewContainer.frame=viewFrame;
    UIImagePickerController * picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    switch (sender.tag) {
        case 20000://Take picture
            
            if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
                picker.sourceType = UIImagePickerControllerSourceTypeCamera;
                
            }else{
                NSLog(@"模拟器无法打开相机");
            }
            [self presentViewController:picker animated:YES completion:nil];
            break;
            
        case 20001://From album
            picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
            [self presentViewController:picker animated:YES completion:nil];
            break;
            
        default:
            
            break;
    }
    
}

-(IBAction)cancelBtnClick:(id)sender
{
    // _CameraHelper.selectOrCancel=@"CANCEL";
    CGRect viewFrame=_photoPickerViewContainer.frame;
    viewFrame.origin.y=768;
    _photoPickerViewContainer.frame=viewFrame;
    // [_CameraHelper stopRunning];
    
    
}

-(NSString * )getSaveKey {
    NSDate *d = [NSDate date];
    int value = arc4random() % 1000;
    return [NSString stringWithFormat:@"/%ld/%ld/%d.jpg",(long)[self getYear:d],(long)[self getMonth:d],value];
}

- (NSInteger)getYear:(NSDate *) date{
    NSDateFormatter *formatter =[[NSDateFormatter alloc] init];
    [formatter setTimeStyle:NSDateFormatterMediumStyle];
    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSInteger unitFlags = NSYearCalendarUnit;
    NSDateComponents *comps = [calendar components:unitFlags fromDate:date];
    NSInteger year=[comps year];
    return year;
}

- (NSInteger)getMonth:(NSDate *) date{
    NSDateFormatter *formatter =[[NSDateFormatter alloc] init];
    [formatter setTimeStyle:NSDateFormatterMediumStyle];
    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSInteger unitFlags = NSMonthCalendarUnit;
    NSDateComponents *comps = [calendar components:unitFlags fromDate:date];
    NSInteger month = [comps month];
    return month;
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    
    [self dismissViewControllerAnimated:NO completion:^{
        
//        CGRect viewFrame=_addDepositView.frame;
//        viewFrame.origin.y=0;
//        _addDepositView.frame=viewFrame;
    }];
    
}
-(UIImage *)imageCompress:(UIImage *)image
{
    UIImage *comImage=image;
    NSData * sendImageData = UIImageJPEGRepresentation(comImage, 1.0);
    NSUInteger sizeOrigin = [sendImageData length];
    NSUInteger sizeOriginKB = sizeOrigin / 1024;
    
    if (sizeOriginKB >100) {
        float a = 100.0000;
        float b = (float)sizeOriginKB;
        float q = sqrtf(a / b);
        
        CGSize sizeImage = [comImage size];
        CGFloat widthSmall = sizeImage.width * q;
        CGFloat heighSmall = sizeImage.height * q;
        CGSize sizeImageSmall = CGSizeMake(widthSmall, heighSmall);
        
        UIGraphicsBeginImageContext(sizeImageSmall);
        CGRect smallImageRect = CGRectMake(0, 0, sizeImageSmall.width, sizeImageSmall.height);
        [image drawInRect:smallImageRect];
        UIImage *smallImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        
        NSData *dataImage = UIImageJPEGRepresentation(smallImage, 1.0);
        sendImageData = dataImage;
        
        comImage= smallImage;
        // [_imageview1.image retain];
    }
    return comImage;
}

-(void)addDepositAlphaViewClick
{
    [_minAmountTextField resignFirstResponder];
    [_maxAmountTextField resignFirstResponder];
    [_depositAmountTextField resignFirstResponder];
    [_addDepositRemarkView resignFirstResponder];
    
   // isLoad=NO;
    [_addDepositScrollView setContentOffset:CGPointMake(0, 0)];
    
   
        CGRect viewFrame=_addDepositScrollView.frame;
        viewFrame.origin.y=0;
        _addDepositScrollView.frame=viewFrame;
    
    

    if ([self.delegate respondsToSelector:@selector(AddNewDepositAlphaViewClick)]) {
        [self.delegate AddNewDepositAlphaViewClick];
    }
}
- (void)textViewDidChange:(UITextView *)textView
{
    if (textView==_addDepositRemarkView)
    {
        if (textView.text.length == 0) {
            _addDepositRemarkViewImage.hidden=NO;
            _addDepositRemarkViewLabel.hidden=NO;
            
        }
        else
        {
            _addDepositRemarkViewImage.hidden=YES;
            _addDepositRemarkViewLabel.hidden=YES;
            
        }
    }
    
}

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
    if (textView==_addDepositRemarkView)
    {
        [UIView animateWithDuration:0.3 animations:^{
            CGRect viewFrame=_addDepositScrollView.frame;
            viewFrame.origin.y=-(_remarkViewContainer.frame.origin.y+_remarkViewContainer.frame.size.height-_addDepositScrollView.contentOffset.y+380-768);
            _addDepositScrollView.frame=viewFrame;
        } completion:^(BOOL finished){
            
        }];
        
    }
    
    return YES;
}
- (void)textViewDidEndEditing:(UITextView *)textView
{
    if (textView==_addDepositRemarkView)
    {
        [_addDepositScrollView setContentOffset:CGPointMake(0, 0)];
        [UIView animateWithDuration:0.3 animations:^{
            CGRect viewFrame=_addDepositScrollView.frame;
            viewFrame.origin.y=0;
            _addDepositScrollView.frame=viewFrame;
        } completion:^(BOOL finished){
            
        }];
        
        
    }
       
    
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
    if (textField==_depositAmountTextField)
    {
        _totalAmountLabel.text=[Global floatConvertPercentile:[_depositAmountTextField.text floatValue]];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
